package otherPractice;

public class Children extends AbstractPeople{


    public Children(int age, String name) {
        super(age, name);
    }

    public double sum(int a, int b, int c){
        int result =  a + b + c;

        return result;
    }

    public static void main(String[] args) {
        System.out.println("1212123");
        assert 2 > 1 : "true";
        System.out.println("2222222");
        assert 2 > 4 : "false";
        System.out.println("3333333");
    }


    public void doQuestion(BaseInterface callback,String question){
            System.out.println("do question");
            String answer = "this is answer";
            callback.callBackResult(answer);
    }


    @Override
    public void sayHello() {

    }

    @Override
    public void askChildren(String question) {

    }








//    public class Producer {
//        private static final String NORMAL_EXCHANGE = "normal_exchange";
//        private static final String NORMAL_QUEUE = "normal_queue";
//        public static void main(String[] args) throws Exception {
//            ConnectionFactory factory = new ConnectionFactory();
//            factory.setHost("localhost");
//            try (Connection connection = factory.newConnection();
//                 Channel channel = connection.createChannel()) {
//                channel.exchangeDeclare(NORMAL_EXCHANGE, "direct");
//                // 设置消息的TTL为10秒
//                AMQP.BasicProperties properties = new AMQP.BasicProperties.Builder()
//                        .expiration("10000")
//                        .build();
//                for (int i = 1; i <= 10; i++) {
//                    String message = "Message " + i;
//                    channel.basicPublish(NORMAL_EXCHANGE, NORMAL_QUEUE, properties, message.getBytes("UTF-8"));
//                    System.out.println("Sent: " + message);
//                }
//            }
//        }
//    }
//
//
//
//
//
//
//
//    public class Consumer {
//        private static final String NORMAL_EXCHANGE = "normal_exchange";
//        private static final String NORMAL_QUEUE = "normal_queue";
//
//        private static final String DEAD_EXCHANGE = "dead_exchange";
//        private static final String DEAD_QUEUE = "dead_queue";
//
//        public static void main(String[] args) throws Exception {
//
//            ConnectionFactory factory = new ConnectionFactory();
//            factory.setHost("localhost");
//            try (Connection connection = factory.newConnection();
//                 Channel channel = connection.createChannel()) {
//                // 声明正常交换机和队列
//                channel.exchangeDeclare(NORMAL_EXCHANGE, "direct");
//
//                // 声明死信交换机和队列
//                channel.exchangeDeclare(DEAD_EXCHANGE, "direct");
//                channel.queueDeclare(DEAD_QUEUE, false, false, false, null);
//                channel.queueBind(DEAD_QUEUE, DEAD_EXCHANGE, "dead_routing_key");
//
//                // 配置正常队列的死信参数
//                java.util.Map<String, Object> args = new java.util.HashMap<>();
//                args.put("x-dead-letter-exchange", DEAD_EXCHANGE);
//                args.put("x-dead-letter-routing-key", "dead_routing_key");
//                channel.queueDeclare(NORMAL_QUEUE, false, false, false, args);
//                channel.queueBind(NORMAL_QUEUE, NORMAL_EXCHANGE, NORMAL_QUEUE);
//
//                System.out.println("Waiting for messages...");
//
//                DeliverCallback deliverCallback = (consumerTag, delivery) -> {
//                    String message = new String(delivery.getBody(), "UTF-8");
//                    System.out.println("Received: " + message);
//                    // 模拟消费异常，拒绝消息
//                    if (message.contains("5")) {
//                        System.out.println("Rejecting message: " + message);
//                        channel.basicReject(delivery.getEnvelope().getDeliveryTag(), false);
//                    } else {
//                        System.out.println("Acknowledging message: " + message);
//                        channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
//                    }
//                };
//                channel.basicConsume(NORMAL_QUEUE, false, deliverCallback, consumerTag -> {});
//
//            }
//
//        }
//
//    }
//
//
//    import com.rabbitmq.client.*;
//
//import java.io.IOException;
//
//    public class DeadLetterConsumer {
//
//        private static final String DEAD_EXCHANGE = "dead_exchange";
//
//        private static final String DEAD_QUEUE = "dead_queue";
//
//        public static void main(String[] args) throws Exception {
//
//            ConnectionFactory factory = new ConnectionFactory();
//
//            factory.setHost("localhost");
//
//            try (Connection connection = factory.newConnection();
//
//                 Channel channel = connection.createChannel()) {
//
//                channel.exchangeDeclare(DEAD_EXCHANGE, "direct");
//
//                channel.queueDeclare(DEAD_QUEUE, false, false, false, null);
//
//                channel.queueBind(DEAD_QUEUE, DEAD_EXCHANGE, "dead_routing_key");
//
//                System.out.println("Waiting for dead letter messages...");
//
//                DeliverCallback deliverCallback = (consumerTag, delivery) -> {
//
//                    String message = new String(delivery.getBody(), "UTF-8");
//
//                    System.out.println("Received dead letter: " + message);
//
//                    channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
//
//                };
//
//                channel.basicConsume(DEAD_QUEUE, false, deliverCallback, consumerTag -> {});
//
//            }
//
//        }
//
//    }


}
